#include "mesh.hpp"
#include <vector>
#include <cmath>
#include <memory>
#include <d3dx10.h>
#include <algorithm>
#include <boost/array.hpp>
#include <functional>
#include <iostream>
#include <fstream>
#include <omp.h>
#include <windows.h>
#include <boost/multi_array.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/lu.hpp>
#include <boost/foreach.hpp>
#include <boost/range.hpp>
#include "timestamp.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include "XForm.h"

using namespace std;
using namespace boost;
namespace ublas = boost::numeric::ublas;
#define foreach BOOST_FOREACH
//int MainWindow;


/*
float calVisibleSalency()
{
	float pixelcolorbuf[500][500][3] ={0}; 
	int i, j, k,index;
	float visiblesaliency=0.0;
	int View[4];
	glutSetWindow( MainWindow);
	glGetIntegerv(GL_VIEWPORT, View);
	int width = View[2], height = View[3];

	for (i = 0; i < width; i++)
	for (j = 0; j < height; j++)
	  for (k = 0; k < 3; k++)
		  pixelcolorbuf[i][j][k] = 0;

	glReadBuffer(GL_FRONT);
	glReadPixels(View[0], View[1], width, height, GL_RGB, GL_FLOAT, pixelcolorbuf);
	for (i = 0; i < width; i++)
	  for (j = 0; j < height; j++)  
		  //R or G component are not zero
		 // if ((pixelcolorbuf[i][j][0] != 0 || pixelcolorbuf[i][j][1] != 0) && (pixelcolorbuf[i][j][2] == 0.0))
		  if (pixelcolorbuf[i][j][2] == 0.0)   //pixel-level saliency 
		  {
			  index = int(255 *pixelcolorbuf[i][j][1]) *256+int(255*pixelcolorbuf[i][j][0]);
			  if (index>= themesh.vert_.size())
		  		;//printf("out of range!\n");
			  else
		  		visiblesaliency=visiblesaliency+themesh.vert_[index].saliency;
		  }
	return visiblesaliency;
}
*/